package com.knowif.backend.controller;

import com.alibaba.fastjson.JSONObject;
import com.knowif.backend.service.InterviewExperienceService;
import com.knowif.backend.service.OfferInterviewService;
import com.knowif.backend.service.OfferService;
import com.knowif.backend.service.StanderSorceService;
import com.knowif.pojo.*;
import com.knowif.search.SearchCondition;
import com.knowif.system.model.RestBean;
import com.knowif.util.ExampleUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wechat")
public class OfferInterviewController {

    @Autowired
    OfferInterviewService offerInterviewService;

    /**
     * offer和面试经历的展示页面
     * @return
     */
    @GetMapping("/offer/interview/index")
    public RestBean<?> index(){
        return offerInterviewService.indexInfo();
    }

    /**
     * offer和面试经历页面查询方法
     * @param key
     * @return
     */
    @PostMapping("/offer/interview/search")
    public RestBean<?> search(@RequestParam("key") String key){
        return offerInterviewService.search(key);
    }


    /**
     * 消息中心接口
     * @param map
     * @return
     */
    @PostMapping("/infoCenter")
    public RestBean getInfo(@RequestBody Map<String, Integer> map) {
        Integer userId = map.get("userId");
        return this.offerInterviewService.getInfo(userId);
    }


    /**
     * 查询offer、interview、comment 以及统计评论感谢收藏数量
     * @param userId
     * @return
     */
    @GetMapping("/offer/interview/comment/select")
    @ResponseBody
    public RestBean selectOfferInterviewComment(@RequestParam("userId") Integer userId){
        Map<String, Object> map = offerInterviewService.selectOfferInterviewComment(userId);
        return RestBean.buildSuccess(map);
    }
}
